package cn.virens.common.project.generator.database.config;

import cn.virens.common.util.exception.APIException;
import org.dromara.hutool.core.date.DateUtil;
import org.dromara.hutool.setting.Setting;

import java.io.Serializable;

@SuppressWarnings("serial")
public class GlobalConfig implements Serializable {
    private final Setting setting;

    private final String module;
    private final String schema;
    private final String author;
    private final String table;
    private final String date;

    public GlobalConfig(Setting setting) throws APIException {
        this.author = System.getProperty("user.name");
        this.schema = setting.get("global.schema");
        this.module = setting.get("global.module");
        this.table = setting.get("global.table");
        this.date = DateUtil.formatToday();
        this.setting = setting;
    }

    public String getDate() {
        return date;
    }

    public String getTable() {
        return table;
    }

    public String getModule() {
        return module;
    }

    public String getSchema() {
        return schema;
    }

    public String getAuthor() {
        return author;
    }

    public String getStr(String key) {
        return setting.getStr(key);
    }

    public boolean getBool(String key) {
        return setting.getBool(key);
    }

}
